Each item in the array is called an element. It is equivalent to a variable of the array type. We tell C which element we want to get hold of by using a subscript value. In the line above we have set the first element of the array to the value 99. Note that the first element of an array is numbered 0. This means that there is no element s [11] since this subscript value goes beyond the end of our array. Rather sadly, it is very unlikely that your C program will notice this and so will let your program fall off the end of the array and do stupid things with the wrong part of memory. This is one of the major joys of C programming!

Once we have created our array we can get hold of individual elements by using a subscript value. If you step the program in the CPIC down beyond the declaration of the array you will assign a value to the first element. The first batsman scored 99, the second 10 and the third 54. As each element is assigned you can see it change. The compiler knows which element to change because the subscript gives the offset into the array each time.

The compiler provides us with a neat way in which we can set an entire array to a sequence of values in one:

const unsigned char goodbye [8] ={'g','o','o','d','b','y','e',0x00};

This would create an array of characters which is called goodbye which contains 8 elements. This is how strings of text are held in C programs. Note that the compiler does not support strings as such, but we can hold arrays of characters this way if we like. We use strings and arrays when we send out messages in lab 5. Note also that we have made the array constant using the const modifier. This means that we cannot update values in the array as our program runs, we can only read them from it. In the case of our message this is not a problem, but it does restrict the usefulness of this somewhat.